//////////////////////////////////////////////////////////////////////////////////////////
// NAME: ApplicationOperations.java							  							//
// AUTHOR: CDT Peter Lofreddo															//
// LAST MODIFIED: 12 February 2012														//
// DESCRIPTION: Contains operations dealing with App Ops.								//
// for Nullwall Application Firewall													//
// LIMITATIONS: 																		//
// CITATIONS: Inside Individual Methods.												//
//																						//
////////////////////////////////////////////////////////////////////////////////////////// 
package com.Nullwall.NullwallApp;

import java.util.List;

import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.Uri;

public class ApplicationOperations extends Main {

	
	public void UninstallApplication(String packageName)
	//////////////////////////////////////////////////////////////////////////////////////////
	// NAME: UninstallApplication(String packageName)					           			//
	// AUTHOR: CDT Peter Lofreddo															//
	// LAST MODIFIED: 02 February 2012														//
	// DESCRIPTION:Uninstalls Package Permanently from Android.					 			//
	// LIMITATIONS:	Must still ask user to permanently uninstall.							//
	// CITATIONS:Adapted from http://android.amberfog.com/?p=98								//
	// 																						//
	////////////////////////////////////////////////////////////////////////////////////////// 
{
	Uri packageURI = Uri.parse("package:"+packageName);
	Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
	startActivity(uninstallIntent);
}

	public void ListAllInstalledApplications()
	//////////////////////////////////////////////////////////////////////////////////////////
	// NAME: ListAllInstalledApplications()					           						//
	// AUTHOR: CDT Peter Lofreddo															//
	// LAST MODIFIED: 01 February 2012														//
	// DESCRIPTION: Lists package names installed on Android Device					 		//
	// LIMITATIONS: 																		//
	// CITATIONS: adapted from http://stackoverflow.com/questions/2695746/					//
	// how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run 				//
	//																						//
	////////////////////////////////////////////////////////////////////////////////////////// 
{
	final PackageManager pm = getPackageManager(); 
	//get a list of installed apps. 
	        List<ApplicationInfo> packages = pm 
	                .getInstalledApplications(PackageManager.GET_META_DATA); 
	 
	        for (ApplicationInfo packageInfo : packages) 
	        { 
	            tv.append("Installed package :" + packageInfo.packageName + "\n");  
	        }
} 
}
